﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Entity;
using DAL;
using Models;
using System.Data.Linq;
using System.Linq.Expressions;
namespace BAL
{
    public class TestPaperPolicyMain : BaseBAL<TestPaperPolicyMainInfo, Models.TestPaperPolicyMain>
    {

        public static IList<TestPaperPolicyMainInfo> GetLists(int subjectId)
        {
            using (var db = DatabaseHelper.GetDashboardData())
            {
                return db.GetTable<Models.TestPaperPolicyMain>().Where(p=>p.SubjectId==subjectId).OrderBy(p=>p.Name).Select(t => TransT2ToT1(t)).ToList();
            }
        }

        public static IList<TestPaperPolicyMainInfo> GetList(int first, int max)
        {
            using (var db = DatabaseHelper.GetDashboardData())
            {
                if (max > 0)
                {
                    return db.GetTable<Models.TestPaperPolicyMain>().OrderByDescending(p=>p.CreateDate).Skip(first).Take(max).Select(t => TransT2ToT1(t)).ToList();
                }
                else
                {
                    return db.GetTable<Models.TestPaperPolicyMain>().OrderByDescending(p => p.CreateDate).Select(t => TransT2ToT1(t)).ToList();
                }
            }
        }
    }
}
